package org.wkg.lesson09;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Demo_905 {

    public static void main(String[] args) throws InterruptedException {
        ThreadPoolExecutor threadPool = new ThreadPoolExecutor(10,
                20, 1, TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(10),
                new ThreadPoolExecutor.DiscardPolicy());


        for (int i = 0; i < 100; i++) {
            int task = i + 1;
            threadPool.submit(() -> {
                System.out.println("执行任务：" + task + " " + Thread.currentThread().getName());
            });
            //TimeUnit.SECONDS.sleep(1);
        }
    }
}
